package com.lyz.anli;

import java.util.Arrays;

/**
 * @ClassName De8xzpx
 * @Description 选择排序
 * @Author 2214361854
 * @Date 2022/2/21 11:52
 * @Version 1.0
 */
public class De8xzpx {
    public static void main(String[] args) {
        int[] arr = {1,42,7,23,20};
        // i=0 j=i+1
        for (int i = 0; i < arr.length; i++) {
            for (int j = i + 1 ; j < arr.length; j++) {
                //如果有比它小的就交换
                if (arr[i]>arr[j]) {
                    int temp = arr[i];
                    arr[i] = arr[j];
                    arr[j] = temp;
                }
            }
        }
        System.out.println(Arrays.toString(arr));
    }
}
